﻿using Microsoft.Extensions.Logging;
using System.Collections.Generic;
using System.Net.Http;

namespace Longbow.Web
{
    /// <summary>
    /// IP定位器配置项
    /// </summary>
    public class IPLocatorOption
    {
        /// <summary>
        /// IP定位器实体类
        /// </summary>
        public IIPLocator Locator { get; set; } = NoneIPLocator.Instance;

        /// <summary>
        /// IP定位器请求地址
        /// </summary>
        public string Url { get; set; }

        /// <summary>
        /// HttpClient 实体类
        /// </summary>
        internal HttpClient HttpClient { get; set; }

        /// <summary>
        /// ILogger 实体类
        /// </summary>
        internal ILogger<IIPLocatorProvider> Logger { get; set; }

        /// <summary>
        /// 获得/设置 缓存时长 默认为 60 * 1000 毫秒
        /// </summary>
        public int Period { get; set; } = 60 * 1000;

        /// <summary>
        /// 获得/设置 IP地址请求超时时间 默认为 3000 毫秒
        /// </summary>
        public int RequestTimeout { get; set; } = 3000;

        /// <summary>
        /// 获得/设置 IP地址
        /// </summary>
        public string IP { get; set; }

        /// <summary>
        /// 获得 本机地址列表
        /// </summary>
        public List<string> Localhosts { get; } = new List<string>(new string[] { "::1", "127.0.0.1" });
    }
}
